package in.muton.panels.paginator.badgehelpers.user;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.auth.roles.DeptRoleCheck;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.model.IModel;

import com.edushare.common.dao.BatchDAO;
import com.edushare.common.vo.Batches;
import com.edushare.common.vo.Departments;
import com.edushare.common.vo.Users;

public class BatchBadgeRoles extends BadgeRoles {

	private static final long serialVersionUID = 100937725057695806L;

	public BatchBadgeRoles(IModel<Batches> batchModel){
		this.batchModel = batchModel;
		
	}
	
	@Override
	public String changeRole(Users user, String role) {
		return "";
	}

	@Override
	public List<String> getOtherRoles(Users user) {
		return new ArrayList<String>();
	}

	@Override
	public String getRole(Users user) {
		return "Student";
	}

	@Override
	public boolean isAdmin() {
		if(batchModel.getObject().getBatchStatus() == Batches.BATCH_GRADUATED)
			return false;
		Departments dept = batchModel.getObject().getCurricula().getDepartment();
		DeptRoleCheck drc = new DeptRoleCheck(dept, EduShareSession.get().getLoggedInUser());
		if(drc.isPrimaryAdmin()||drc.isUnivAdmin())
			return true;
		return false;
	}

	@Override
	public String removeUser(Users user) {
		new BatchDAO(EduShareSession.get().getSessionORMInterface()).
			removeStudent(batchModel.getObject(), user);
		return "";
	}

	@Override
	public boolean isInvited(Users user) {
		return false;
	}

	private IModel<Batches> batchModel = null;

	@Override
	public boolean isLastAdmin(Users user) {
		return false;
	}
}
